package com.zhou.mymvpdemo.impcontract;

import android.util.Log;

import com.zhou.mymvpdemo.bean.ServiceInfo;
import com.zhou.mymvpdemo.interfaces.TaskDataSource;

import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;





/**
 * Created by Administrator on 2017/8/2.
 */

public class SourceDataImp implements TaskDataSource {
    public  static final String TAG="SourceDataImp";
    private SourceDataImp(){}
    protected static SourceDataImp instance;

    public static SourceDataImp getInstance() {
        if (instance == null){
         return    instance = new SourceDataImp();

        }else {
            return instance;

        }

    }
    /*获取本地数据的方法*/
    @Override
    public void addLocalData() {

    }

    @Override
    public void addRemoteData(Callback callback) {

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://192.168.1.174:8080/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();

        LoginServer loginServer = retrofit.create(LoginServer.class);
        Call<ServiceInfo> loginResult = loginServer.getLoginResult();
        loginResult.enqueue(new retrofit2.Callback<ServiceInfo>() {
                                @Override
                                public void onResponse(Call<ServiceInfo> call, Response<ServiceInfo> response) {
                                    Log.d(TAG,"请求成功了");
                                }

                                @Override
                                public void onFailure(Call<ServiceInfo> call, Throwable t) {

                                }
                            }


        );

    /*获取网络数据的方法*/

        //这里可以用retrofit
    }


}
